<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-row>
        <el-col :span="8">
          <el-input placeholder="请输入查询内容">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <el-table :data="orderlist" border stripe>
        <el-table-column type="index"> </el-table-column>
        <el-table-column label="订单编号" prop="order_number">
        </el-table-column>
        <el-table-column label="订单价格" prop="order_price"> </el-table-column>
        <el-table-column label="是否付款" prop="pay_status">
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.pay_status === 1"
              >已付款</el-tag
            >
            <el-tag type="danger">未付款</el-tag>
          </template></el-table-column
        >
        <el-table-column label="是否发货" prop="is_send"> </el-table-column>
        <el-table-column label="下单时间" prop="create_time">
          <template slot-scope="scope">
            {{ scope.row.create_time | dataFormat }}
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              type="primary"
              icon="el-icon-edit"
              size="mini"
              @click="showbox"
            ></el-button>
            <el-button
              type="success"
              icon="el-icon-location"
              size="mini"
              @click="showadss"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryinfo.pagenum"
        :page-sizes="[5, 15, 20, 100]"
        :page-size="queryinfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-card>
    <el-dialog title="修改订单" :visible.sync="dialogVisible" width="30%">
      <el-form
        :model="addruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="100px"
        class="demo-ruleForm"
        @close="close"
      >
        <el-form-item label="地址" prop="name">
          <el-cascader :options="city" v-model="addruleForm.name" clearable></el-cascader>
        </el-form-item>
        <el-form-item label="详细地址" prop="ress">
          <el-input v-model="addruleForm.ress"></el-input> </el-form-item
      ></el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <el-dialog title="物流详情" :visible.sync="adssdialogVisible" width="30%">
<el-timeline>
    <el-timeline-item
      v-for="(activity, index) in progressinfo"
      :key="index"
      :timestamp="activity.time">
      {{activity.context}}
    </el-timeline-item>
  </el-timeline>
    </el-dialog>
  </div>
</template>

<script>
import city from './citydata'
export default {
  data() {
    return {
      queryinfo: {
        query: "",
        pagenum: 1,
        pagesize: 10,
      },
      total: 0,
      orderlist: [],
      dialogVisible: false,
      adssdialogVisible: false,
      addruleForm: {
        name: [],
        ress: "",
      },
      rules: {
        name: [{ required: true, message: "请选择", trigger: "blur" }],
        ress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
      },
      city,
      progressinfo:[]
    };
  },
  created() {
    this.getOrderList();
  },
  methods: {
    async getOrderList() {
      var { data: resp } = await this.$http.get("orders", {
        params: this.queryinfo,
      });
      console.log(resp.data);
      this.total = resp.data.total;
      this.orderlist = resp.data.goods;
    },
    handleSizeChange(newsize) {
      this.queryinfo.pagesize = newsize;
      this.getOrderList();
    },
    handleCurrentChange(newpage) {
      this.queryinfo.pagenum = newpage;
      this.getOrderList();
    },
    //修改地址
    showbox() {
      this.dialogVisible = true;
    },
    close(){
        this.$refs.ruleForm.resetField()
    },
    async showadss(){
      var {data:resp}= await  this.$http.get('/kuaidi/804909574412544580')
      this.progressinfo=resp.data
        this.adssdialogVisible = true;
        console.log(this.progressinfo)
    }
  },
};
</script>

<style lang="less" scoped>
@import '../../plugins/timeline/timeline.css';
@import '../../plugins/timeline-item/timeline-item.css';
</style>
